#!/bin/bash

# 下载nvm
wget https://github.com/nvm-sh/nvm/archive/refs/tags/v0.38.0.tar.gz

# 创建nvm目录
mkdir -p /home/apple/soft

# 解压nvm到指定目录
tar -zxvf v0.38.0.tar.gz -C /home/apple/soft

# 编辑.bashrc文件，添加nvm配置
echo 'export NVM_DIR="/home/apple/soft"' >> ~/.bashrc
echo '[ -s "$NVM_DIR/nvm-0.38.0/nvm.sh" ] && \. "$NVM_DIR/nvm-0.38.0/nvm.sh"  # This loads nvm' >> ~/.bashrc
echo '[ -s "$NVM_DIR/nvm-0.38.0/bash_completion" ] && \. "$NVM_DIR/nvm-0.38.0/bash_completion"  # This loads nvm bash_completion' >> ~/.bashrc

# 使配置生效
source ~/.bashrc

# 检查nvm是否安装成功
nvm -v